import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '编码',
    align: "center",
    sorter: true,
    dataIndex: 'code'
  },
  {
    title: '名称',
    align: "center",
    sorter: true,
    dataIndex: 'name'
  },
  {
    title: '版本号',
    align: "center",
    dataIndex: 'versionNumber'
  },
  {
    title: '操作时间',
    align: "center",
    sorter: true,
    dataIndex: 'operateTime'
  },
  //  {
  //   title: '操作员ID',
  //   align:"center",
  //   dataIndex: 'operatorId'
  //  },
  {
    title: '操作员名称',
    align: "center",
    dataIndex: 'operatorName'
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'remark'
  },
  {
    title: '第三方编码',
    align: "center",
    dataIndex: 'thirdPartyCode',
    ifShow: false
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "编码",
    field: "code",
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "名称",
    field: "name",
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "操作时间",
    field: "operateTime",
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    colProps: { span: 6 },
  },
  {
    label: "操作员名称",
    field: "operatorName",
    component: 'Input',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编码',
    field: 'code',
    component: 'Input',
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入名称!' },
      ];
    },
  },
  {
    label: '版本号',
    field: 'versionNumber',
    component: 'Input',
  },
  {
    label: '操作时间',
    field: 'operateTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: () => {
      return [
        { required: true, message: '请选择操作时间!' },
      ];
    },
  },
  {
    label: '操作员ID',
    field: 'operatorId',
    component: 'Input',
    show: false
  },
  {
    label: '操作员名称',
    field: 'operatorId',
    component: 'JSelectUser',
    componentProps: {
      labelKey: 'realname',
      rowKey: 'id',
      isRadioSelection: true,
      showButton: false
    }
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
    ifShow: false
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];
//子表单数据
//子表表格配置
export const busSupplyDemandBalanceItemColumns: JVxeColumn[] = [
  {
    title: '供需平衡ID',
    key: 'supplyDemandBalanceId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '货组组织ID',
    key: 'cargoGroupOrganizationId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '货组组织名称',
    key: 'cargoGroupOrganizationName',
    type: JVxeTypes.slot,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
    slotName: 'organizationSlot'
  },
  {
    title: '料品ID',
    key: 'materialId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '料品编号',
    key: 'materialCode',
    type: JVxeTypes.slot,
    slotName: 'materialSlot',
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '料品名称',
    key: 'materialName',
    type: JVxeTypes.normal,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '料品规格',
    key: 'spec',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '单位ID',
    key: 'unitId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '单位名称',
    key: 'unitName',
    width: "200px",
    type: JVxeTypes.normal,
  },
  {
    title: '属性',
    key: 'attribute',
    type: JVxeTypes.select,
    options: [{ value: 0, label: '制造件' }, { value: 1, label: '采购件' }, { value: 2, label: '外购件' }, { value: 3, label: '委外加工件' }],
    defaultValue: 0,
    width: "200px",
    placeholder: '请输入${title}',
  },
  {
    title: '请购数量',
    key: 'buyingRequisitionQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '采购订单数量',
    key: 'purchaseOrderQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '生产订单数量',
    key: 'produceOrderQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '未检数量',
    key: 'notInspectedQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '现存量',
    key: 'onHandQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '销售订单数量',
    key: 'saleOrderQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '预测订单数量',
    key: 'calculateOrderQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '主需求计划数量',
    key: 'masterDemandPlanQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '安全库存数量',
    key: 'safetyStockQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '在制备料需求数量',
    key: 'inProcessMaterialQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '委外备料需求数量',
    key: 'outsourcingMaterialQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '备注',
    key: 'remark',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '第三方编码',
    key: 'thirdPartyCode',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
]


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}